//
//  CellOfFourPic.m
//  ProjectA_ManualGuest
//
//  Created by dingcong on 16/6/17.
//  Copyright © 2016年 丁聪. All rights reserved.
//

#import "CellOfFourPic.h"
#import "Masonry.h"
#import "PrefixHeader.pch"
#import "UIImageView+WebCache.h"
@implementation CellOfFourPic

- (void)dealloc{
    [super dealloc];
    [_viewOfCell release];
    [_imageOfNew release];
    [_LableOfNew release];
    [_imageOfHot release];
    [_lableOfHot release];
    [_imageOfStore release];
    [_lableOfStore release];
    [_imageOfClassify release];
    [_lableOfClassify release];
    [_model release];
    
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier])
    {
        [self creat];
    }
    
    return self;
}

- (void)creat{
    
    self.contentView.backgroundColor = [UIColor colorWithRed:246.0 / 256.0f green:246.0 / 256.0f blue:246.0 / 256.0f alpha:1];
    self.viewOfCell = [[UIView alloc]init];
    self.viewOfCell.backgroundColor = [UIColor whiteColor];
    [self.contentView addSubview:self.viewOfCell];
    [self.viewOfCell mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.contentView.mas_top).offset(0);
        make.centerY.equalTo(self.contentView.mas_centerY);
        make.height.equalTo(self.contentView.mas_height).offset(- 10);
        make.width.equalTo(self.contentView.mas_width);
    }];
    
    
    
    [self.viewOfCell release];
    
    self.imageOfNew = [[UIImageView alloc]init];
    [self.viewOfCell addSubview:self.imageOfNew];
//    self.imageOfNew.backgroundColor = [UIColor cyanColor];
    [self.imageOfNew mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.viewOfCell.mas_top).offset(15);
        make.leading.equalTo(self.viewOfCell.mas_leading).offset(22);
        make.width.offset(SCREEN_WIDTH / 4 - 30)  ;
        make.height.offset(50);
        
    }];
    
    [self.imageOfNew release];
    
    
    
    self.LableOfNew = [[UILabel alloc]init];
    [self.viewOfCell addSubview:self.LableOfNew];
//    self.LableOfNew.backgroundColor = [UIColor redColor];
    
    [self.LableOfNew mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(self.imageOfNew.mas_centerX);
        make.top.equalTo(self.imageOfNew.mas_bottom).offset(10);
        make.width.offset(SCREEN_WIDTH / 4);
        make.height.offset(25);
    }];
    
    self.LableOfNew.font = [UIFont systemFontOfSize:13];
    self.LableOfNew.textColor = [UIColor grayColor];
    self.LableOfNew.textAlignment = NSTextAlignmentCenter;
    [self.LableOfNew release];
    
    
    self.imageOfHot = [[UIImageView alloc]init];
    [self.viewOfCell addSubview:self.imageOfHot];
//    self.imageOfHot.backgroundColor = [UIColor cyanColor];
    [self.imageOfHot mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.viewOfCell.mas_top).offset(15);
        make.leading.equalTo(self.imageOfNew.mas_trailing).offset(27);
        make.width.offset(SCREEN_WIDTH / 4 - 30)  ;
        make.height.equalTo(self.imageOfNew.mas_height);
    }];
    
    [self.imageOfHot release];
    
    
    
    self.lableOfHot = [[UILabel alloc]init];
    [self.viewOfCell addSubview:self.lableOfHot];
//    self.lableOfHot.backgroundColor = [UIColor redColor];
    
    [self.lableOfHot mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.imageOfHot.mas_bottom).offset(10);
        make.centerX.equalTo(self.imageOfHot.mas_centerX);
        make.width.offset(SCREEN_WIDTH / 4 - 15);
        make.height.offset(25);
    }];
    self.lableOfHot.textColor = [UIColor grayColor];
    self.lableOfHot.font = [UIFont systemFontOfSize:13];
     self.lableOfHot.textAlignment = NSTextAlignmentCenter;
    
    [self.lableOfHot release];
    
    
    self.imageOfStore = [[UIImageView alloc]init];
    [self.viewOfCell addSubview:self.imageOfStore];
//    self.imageOfStore.backgroundColor = [UIColor cyanColor];
    [self.imageOfStore mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.viewOfCell.mas_top).offset(15);
        make.leading.equalTo(self.imageOfHot.mas_trailing).offset(27);
        make.width.offset(SCREEN_WIDTH / 4 - 30)  ;
        make.height.equalTo(self.imageOfNew.mas_height);
    }];
    
    [self.imageOfStore release];
    
    
    
    self.lableOfStore = [[UILabel alloc]init];
    [self.viewOfCell addSubview:self.lableOfStore];
//    self.lableOfStore.backgroundColor = [UIColor redColor];
    
    [self.lableOfStore mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.imageOfStore.mas_bottom).offset(10);
        make.centerX.equalTo(self.imageOfStore.mas_centerX);
        make.width.offset(SCREEN_WIDTH / 4 - 10);
        make.height.offset(25);
    }];
    
    self.lableOfStore.textColor = [UIColor grayColor];
    self.lableOfStore.font = [UIFont systemFontOfSize:13];
     self.lableOfStore.textAlignment = NSTextAlignmentCenter;
    [self.lableOfStore release];
    
    
    self.imageOfClassify = [[UIImageView alloc]init];
    [self.viewOfCell addSubview:self.imageOfClassify];
//    self.imageOfClassify.backgroundColor = [UIColor cyanColor];
    [self.imageOfClassify mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.viewOfCell.mas_top).offset(15);
        make.leading.equalTo(self.imageOfStore.mas_trailing).offset(27);
        make.width.offset(SCREEN_WIDTH / 4 - 30)  ;
        make.height.equalTo(self.imageOfNew.mas_height);
    }];
    
    [self.imageOfClassify release];
    
    
    
    self.lableOfClassify = [[UILabel alloc]init];
    [self.viewOfCell addSubview:self.lableOfClassify];
//    self.lableOfClassify.backgroundColor = [UIColor redColor];
    
    [self.lableOfClassify mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.imageOfClassify.mas_bottom).offset(10);
        make.centerX.equalTo(self.imageOfClassify.mas_centerX);
        make.width.offset(SCREEN_WIDTH / 4 - 10);
        make.height.offset(25);
    }];
    self.lableOfClassify.font = [UIFont systemFontOfSize:13];
    
    self.lableOfClassify.textColor = [UIColor grayColor];
     self.lableOfClassify.textAlignment = NSTextAlignmentCenter;
    [self.lableOfClassify release];
    
    
}

- (void)setModel:(ModelOfMaterial *)model{
    for (NSInteger i = 0; i < model.arrOfFirst.count; i++) {
        
        
        if (i == 0)
        {
            NSURL *url = [[model.arrOfFirst objectAtIndex:i]objectForKey:@"pic"];
            [self.imageOfNew sd_setImageWithURL:url placeholderImage:nil];
            
            self.LableOfNew.text = [[model.arrOfFirst objectAtIndex:i]objectForKey:@"name"];
            
            
        }
        else if (i == 1)
        {
            NSURL *url = [[model.arrOfFirst objectAtIndex:i]objectForKey:@"pic"];
            [self.imageOfHot sd_setImageWithURL:url placeholderImage:nil];
            self.lableOfHot.text = [[model.arrOfFirst objectAtIndex:i]objectForKey:@"name"];
       
           
            
        }
        else if (i == 2)
        {
            NSURL *url = [[model.arrOfFirst objectAtIndex:i]objectForKey:@"pic"];
            [self.imageOfStore sd_setImageWithURL:url placeholderImage:nil];
            self.lableOfStore.text = [[model.arrOfFirst objectAtIndex:i]objectForKey:@"name"];
        }
        else if(i == 3)
        {
            NSURL *url = [[model.arrOfFirst objectAtIndex:i]objectForKey:@"pic"];
            [self.imageOfClassify sd_setImageWithURL:url placeholderImage:nil];
            self.lableOfClassify.text = [[model.arrOfFirst objectAtIndex:i]objectForKey:@"name"];
        
        }
    }
    
    
    
}




@end
